﻿Imports System.Data.OleDb

Public Class Search
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Request.Params("title") <> "" Then
            Dim sql As String = "INSERT INTO search (word,UserName) VALUES (@f1,@f2)"
            Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
            Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)
            cmd.Parameters.AddWithValue("@f1", Request.QueryString("title"))
            cmd.Parameters.AddWithValue("@f2", User.Identity.Name)
            conn.Open()
            cmd.ExecuteNonQuery()
            conn.Close()
            cmd.Dispose()
            conn.Dispose()
        End If
    End Sub

    Protected Sub btn_search_Click(sender As Object, e As EventArgs) Handles btn_search.Click
        Response.Redirect("Search.aspx?title=" & TB_search.Text)
    End Sub
End Class